myApp.controller('signinCtrl',function($scope, $state, $http, $cookieStore){
	// var expireDate = new Date();
 	// 	expireDate.setDate(expireDate.getDate() + 30);//设置cookie保存30天
	// $cookieStore.put("name", "zxadas1", {expires:new Date(new Date().getTime()+5000)});
	// var name = $cookieStore.get("name");
	// console.log(name)
	var userdata = {};
	$scope.submitForm = function(){
		var data = $scope.userdata
		$http({
			method: 'post',
			url: 'http://127.0.0.1:8008/login',
			headers:{
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: data
		}).success(function(data){
			if(data == 'not_user'){
				alert("邮箱不存在！");
				$state.reload();
			}else if(data == 'user'){
				alert("登陆成功");
				$state.go("/");
			}else if(data == 'admin'){
				alert("登陆成功");
				$state.go("/admin");
			}else{
				alert("用户名或密码错误!")
				$state.reload();
			}
		}).error(function(data){
			alert(data)
		});
	};
});